package  com.edu.base.ums.memberAccountRecord.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import  com.edu.base.ums.memberAccountRecord.domain.ClsMemberAccountRecord;
import  com.edu.base.ums.memberAccountRecord.service.IClsMemberAccountRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 账户流水记录 包含金额、积分Controller
 * 
 * @author luzs
 * @date 2021-06-07
 */
@RestController
@RequestMapping("/member/memberAccountRecord")
public class ClsMemberAccountRecordController extends BaseController
{
    @Autowired
    private IClsMemberAccountRecordService clsMemberAccountRecordService;

    /**
     * 查询账户流水记录 包含金额、积分列表
     */
    @PreAuthorize("@ss.hasPermi('member:memberAccountRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClsMemberAccountRecord clsMemberAccountRecord)
    {
        startPage();
        List<ClsMemberAccountRecord> list = clsMemberAccountRecordService.selectClsMemberAccountRecordList(clsMemberAccountRecord);
        return getDataTable(list);
    }

    /**
     * 导出账户流水记录 包含金额、积分列表
     */
    @PreAuthorize("@ss.hasPermi('member:memberAccountRecord:export')")
    @Log(title = "用户账户流水", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ClsMemberAccountRecord clsMemberAccountRecord)
    {
        List<ClsMemberAccountRecord> list = clsMemberAccountRecordService.selectClsMemberAccountRecordList(clsMemberAccountRecord);
        ExcelUtil<ClsMemberAccountRecord> util = new ExcelUtil<ClsMemberAccountRecord>(ClsMemberAccountRecord.class);
        return util.exportExcel(list, "memberAccountRecord");
    }

    /**
     * 获取账户流水记录 包含金额、积分详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:memberAccountRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(clsMemberAccountRecordService.selectClsMemberAccountRecordById(id));
    }

    /**
     * 新增账户流水记录 包含金额、积分
     */
    @PreAuthorize("@ss.hasPermi('member:memberAccountRecord:add')")
    @Log(title = "用户账户流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClsMemberAccountRecord clsMemberAccountRecord)
    {
        return toAjax(clsMemberAccountRecordService.insertClsMemberAccountRecord(clsMemberAccountRecord));
    }

    /**
     * 修改账户流水记录
包含金额、积分
     */
    @PreAuthorize("@ss.hasPermi('member:memberAccountRecord:edit')")
    @Log(title = "用户账户流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClsMemberAccountRecord clsMemberAccountRecord)
    {
        return toAjax(clsMemberAccountRecordService.updateClsMemberAccountRecord(clsMemberAccountRecord));
    }

    /**
     * 删除账户流水记录 包含金额、积分
     */
    @PreAuthorize("@ss.hasPermi('member:memberAccountRecord:remove')")
    @Log(title = "用户账户流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(clsMemberAccountRecordService.deleteClsMemberAccountRecordByIds(ids));
    }
}
